<template>
  <div class="operationalManagement">
    operationalManagement
    <div class="search">
      <el-input placeholder="请输入内容" v-model="search" clearable size="large"></el-input>
      <el-button type="primary" icon="el-icon-search">搜索</el-button>
      <el-button type="primary">
        新增
        <i class="el-icon-circle-plus el-icon--right"></i>
      </el-button>
    </div>
    <el-table stripe border :data="tableData" style="width: 100%">
      <el-table-column label="ID" prop="id"></el-table-column>
      <el-table-column label="业务代号" prop="ip"></el-table-column>
      <el-table-column label="业务名称" prop="groupName"></el-table-column>
      <el-table-column label="潜龙业务id" prop="bizCount"></el-table-column>
      <el-table-column label="管理员姓名" prop="processCount"></el-table-column>
      <el-table-column label="创建时间" prop="leftMemory|"></el-table-column>
      <el-table-column label="更新时间" prop="leftMemory|"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" type="danger" @click="deleteOperation(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: '',

  data() {
    return {
      search: "",
      tableData: [
        // {
        //   "id": 657789,               // 业务id
        //   "code": "living",          // 业务代号
        //   "name": "直播业务",    // 业务名称
        //   "bigdragonId": "1659864", // 潜龙业务id
        //   "admin": "xxx",         // 管理员姓名
        //   "createTime": 13564986523000,      // 创建时间，单位：毫秒
        //   "updateTime": 13564986523000    // 更新时间，单位：毫秒
        // }
      ]
    };
  },
  methods:{
    getList(){
      this.$ajax({
      method: "get",
      url: "/biz/list"
    })
      .then(res => {
        this.tableData = res.data.data.list;
      })
      .catch(err => {
        console.log(err);
      });
    },
    deleteOperation(id){
      this.$confirm("此操作将永久删除该机器, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$ajax({
            method: "delete",
            url: "/machine/" + id
          }).then(res => {
            if (res.success == true) {
              this.$message({
                type: "success",
                message: "删除成功!"
              });
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    }
  },
  mounted() {
    this.getList();
  }
}
</script>

<style lang='less' scoped>
.el-input {
  width: 10%;
  margin: 20px 10px 20px 50px;
}
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>
